﻿using System;

namespace Pibby.Core
{
	public abstract class DisposableObject : IDisposable
	{
		public void Dispose()
		{
			this.Dispose(true);
			GC.SuppressFinalize(this);
		}

		protected virtual void Dispose(bool programmaticallyInvoked)
		{
			if (!this.Disposed)
			{
				ReleaseUnmanagedResources();

				if (programmaticallyInvoked)
				{
					ReleaseManagedResources();
				}

				this.Disposed = true;
			}
		}

		protected virtual void ReleaseUnmanagedResources() 
		{
			/* for subclasses */
		}

		protected virtual void ReleaseManagedResources() 
		{ 
			/* for subclasses */
		}

		public bool Disposed
		{
			get;
			private set;
		}
	}
}
